﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MRefunds.aspx.cs" Inherits="mrefunds" EnableEventValidation="false" %>

<%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<%@ Register TagPrefix="lr" TagName="LoanRepayment" Src="~/Controls/LoanRepayment.ascx" %>

<asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        
        function DisableF5(evt) {
            var evt = (evt) ? evt : ((event) ? event : null);
            var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
            if (event.keyCode == 116) {
                evt.keyCode = 0;
                return false;
            }
            if(window.event && window.event.keyCode == 505)
            {
                return false;

            }
        }
        document.onkeydown = DisableF5;
        document.oncontextmenu = function () { return false; }
    </script>
    <style type="text/css">
        .text_bold {
            font-weight:bold;
        }
        .text_right {
            text-align: right;
        }

    </style>
</asp:Content>

<asp:Content ID="ClassifiersContnet" ContentPlaceHolderID="MainContent" runat="Server">

    <asp:Panel ID="emptyPanel" runat="server" Visible="false">
        <div align="center">
            <h1>Carte de credit</h1>
        </div>
    </asp:Panel>

    <div class="module" style="width: 610px; height: 75px; float: left;">
        <div class="moduleHeader">
            $ Make Repayment for
            <asp:Label ID="clientNameLabelID" runat="server"></asp:Label>
            / Start UP (<asp:Label runat="server" ID="loanLabelID"></asp:Label>)
        </div>
        <div class="module_content">
            <div class="table">
                <div class="row">
                    <div class="cell">Date*</div>
                    <div class="cell">
                        <asp:TextBox ID="transactionDateTextBox" runat="server" Width="70px"></asp:TextBox>
                        <ajax:CalendarExtender ID="transactionDateCalendarExtender" runat="server" TargetControlID="transactionDateTextBox"/>
                    </div>
                    <div class="cell">Amount*</div>
                    <div class="cell">
                        <asp:TextBox runat="server" ID="transactionAmounTextBox" Width="70px"></asp:TextBox>
                    </div>
                    <div class="cell">
                        <asp:CheckBox runat="server" ID="isPenalitateCheckBoxID" Checked="true" Text="Penalitate" /></div>
                    <div class="cell">
                        <asp:Button ID="infoBoxOkButton" runat="server" Text="Ok" Width="50px" OnClick="saveButton_Click" />
                    </div>
                    <div class="cell">
                        <asp:Button ID="infoBoxCancelButtonID" runat="server" Text="Cancel" Width="55px" OnClick="cancelButton_Click" />
                    </div>
                    <asp:HiddenField ID="editPayIDHiddenFieldID" runat="server" />                    
                </div>
            </div>
        </div>
    </div>

    <asp:Panel runat="server" ID="startUpPanel">
        <div class="table">
            <div class="row alt">
                <div class="cell">Disbursement Date</div>
                <div class="cell">
                    <asp:Label runat="server" ID="disbursementDateLabel"></asp:Label>
                </div>
                <div class="cell">&nbsp;</div>
                <div class="cell">Loan Purpose</div>
                <div class="cell">
                    <asp:Label runat="server" ID="loanPurposeLabel"></asp:Label>
                </div>
            </div>
            <div class="row">
                <div class="cell">Currency</div>
                <div class="cell">
                    <asp:Label runat="server" ID="currencyLabel"></asp:Label>
                </div>
                <div class="cell">&nbsp;</div>
                <div class="cell">Approved Amount</div>
                <div class="cell">
                    <asp:Label runat="server" ID="approvedAmountLabel"></asp:Label>
                </div>
            </div>
            <div class="row alt">
                <div class="cell">Loan Officer</div>
                <div class="cell">
                    <asp:Label runat="server" ID="loanOfficerLabel"></asp:Label>
                </div>
                <div class="cell">&nbsp;</div>
                <div class="cell">Disburse Amount</div>
                <div class="cell">
                    <asp:Label runat="server" ID="disburseAmountLabel"></asp:Label>
                </div>
            </div>
            <div class="row">
                <div class="cell">&nbsp;</div>
                <div class="cell">&nbsp;</div>
                <div class="cell">&nbsp;</div>
                <div class="cell">Arrears By</div>
                <div class="cell">
                    <asp:Label runat="server" ID="arrearsByLabel"></asp:Label>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <br />
    </asp:Panel>

    <br />
    <ajax:TabContainer ID="refundsTabContainer" runat="server" CssClass="ajax__myTab" Width="100%" ActiveTabIndex="0">
        <ajax:TabPanel ID="accountDetailTabPanel" runat="server">
            <HeaderTemplate>&nbsp; Account Detail &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left; width: 95%;">

                    <asp:Panel ID="accountDetailPanel" runat="server" Visible="true">
                        <div class="table">
                            <div class="row alt" id="1">
                                <div class="cell">Repayment Strategy</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="repaymentStrategyLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div1">
                                <div class="cell">Repayments</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="repaymentsLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div2">
                                <div class="cell">Amortization</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="amortizationLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div3">
                                <div class="cell">Interest</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div4">
                                <div class="cell">Grace: On Principal Payment</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="gracePrincipalLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div5">
                                <div class="cell">Grace: On Interest Payment</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="graceInterestLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div6">
                                <div class="cell">Grace on Arrears Ageing</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="graceArrearsLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div7">
                                <div class="cell">Fund Source</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="fundSourceLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div8">
                                <div class="cell">Interest Free Period</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestFreePeriodLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div9">
                                <div class="cell">Interest Calculation Period</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestCalculationPeriodLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div10">
                                <div class="cell">Interest Type</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestTypeLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div11">
                                <div class="cell">Submitted on</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="submittedOnLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div12">
                                <div class="cell">Approved on</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="approvedOnLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row" id="Div13">
                                <div class="cell">Disbursed on</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="disbursedOnLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt" id="Div14">
                                <div class="cell">Matures on</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="matureseOnLabel"></asp:Label>
                                </div>
                            </div>
                        </div>
                    </asp:Panel>

                </div>
            </ContentTemplate>
        </ajax:TabPanel>
        <ajax:TabPanel runat="server" ID="summaryTabPanel">
            <HeaderTemplate>&nbsp; Summary &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left; width: 95%;">

                    <asp:Panel ID="summaryPanel" runat="server" Visible="true">
                        <div class="table" id="divTableSummary">
                            <div class="row alt text_bold" id="divCaptioinSummary">
                                <div class="cell">&nbsp;</div>
                                <div class="cell">Original</div>
                                <div class="cell">Paid</div>
                                <div class="cell">Waived</div>
                                <div class="cell">Written Off</div>
                                <div class="cell">Outstanding</div>
                                <div class="cell">Over Due</div>
                            </div>
                            <div class="row text_right" id="divPrincipalSummary">
                                <div class="cell text_bold">Principal</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalOriginalLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalPaidLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalWaivedLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalWrittenOffLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalOutstandingLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="principalOverDueLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt text_right" id="divInterestSummary">
                                <div class="cell text_bold">Interest</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestOriginalLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestPaidLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestWaivedLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestWrittenOffLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestOutstandingLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="interestOverDueLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row text_right" id="divFeesSummary">
                                <div class="cell text_bold">Fees</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesOriginalLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesPaidLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesWaivedLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesWrittenOffLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesOutstandingLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="feesOverDueLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row alt text_right" id="divPenaltiesSummary">
                                <div class="cell text_bold">Penalties</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesOriginalLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesPaidLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesWaivedLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesWrittenOffLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesOutstandingLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="penaltiesOverDueLabel"></asp:Label>
                                </div>
                            </div>
                            <div class="row text_right text_bold" id="divTotalSummary">
                                <div class="cell text_bold">Total</div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalOriginalLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalPaidLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalWaivedLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalWrittenOffLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalOutstandingLabel"></asp:Label>
                                </div>
                                <div class="cell">
                                    <asp:Label runat="server" ID="totalOverDueLabel"></asp:Label>
                                </div>
                            </div>
                        </div>
                    </asp:Panel>

                </div>
            </ContentTemplate>
        </ajax:TabPanel>
        <ajax:TabPanel runat="server" ID="repaymentScheduleTabPanel">
            <HeaderTemplate>&nbsp; Repayment Schedule &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left;">
                    <asp:Panel ID="repaymentSchedulePanel" runat="server">

                        <asp:GridView ID="refundGridView" runat="server" AutoGenerateColumns="false" ShowFooter="false">
                            <AlternatingRowStyle CssClass="alt" />
                            <Columns>
                                <asp:BoundField DataField="iterationID" HeaderText=" # " ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="days" HeaderText=" # Days " ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="dateID" HeaderText=" Date " DataFormatString="{0:d MMMM yyyy}" HtmlEncode="false" />
                                <asp:BoundField DataField="PaidDate" HeaderText=" Paid Date " DataFormatString="{0:d MMMM yyyy}" HtmlEncode="false" />
                                <asp:CheckBoxField DataField="isFinID" />
                                <asp:BoundField DataField="principalDueID" HeaderText=" Principal Due " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="balanceOfLoan" HeaderText=" Balance " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="interestID" HeaderText=" Interest " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="feesID" HeaderText=" Ex. Rate " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="penaltiesID" HeaderText=" Penalties " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="dueID" HeaderText=" Due " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="paidID" HeaderText=" Paid " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="inAdvanceID" HeaderText=" In Advance " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="lateID" HeaderText=" Late " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="outstandingID" HeaderText=" Outstanding " DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                            </Columns>
                        </asp:GridView>
                        
                    </asp:Panel>
                </div>
            </ContentTemplate>
        </ajax:TabPanel>
        <ajax:TabPanel runat="server" ID="transactionsTabPanel">
            <HeaderTemplate>&nbsp; Transactions &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left; width: 95%;">
                    <asp:Panel ID="transactionsPanel" runat="server" Visible="true">
                        <asp:HyperLink runat="server" ID="exportTransactionHyperLinkID" Text="EXPORT" Target="_blank"></asp:HyperLink>
                        <asp:GridView ID="tranzactionGridView" runat="server" AutoGenerateColumns="false" ShowFooter="true" 
                            caption="Tranzactions Activity"                             
                            OnRowDeleting="tranzactionGridView_RowDeleting"
                            OnRowEditing="tranzactionGridView_RowEditing">
                            <AlternatingRowStyle CssClass="alt" />
                            <Columns>
                                <asp:BoundField DataField="TranzactionID" HeaderText=" ID " />
                                <asp:BoundField DataField="TranzactionsOffice" HeaderText=" Office " />                                
                                <asp:TemplateField HeaderText=" Tranzaction Date " ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right">
                                    <ItemTemplate>
                                        <asp:Label ID="TranzactionDateLabelID" runat="server" Text='<%# Bind("TranzactionDate","{0:dd MMMM yyyy}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label ID="fTranzactionDate" runat="server" Text='<%# string.Format("{0:dd MMMM yyyy}", fTranzactionDate) %>'></asp:Label>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText=" Transaction Type " ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Label ID="TranzactionAmountLabelID" runat="server" Text='<%# Bind("Type") %>'></asp:Label>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label ID="fTranzactionDate" runat="server" Text="Disbursment"></asp:Label>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText=" Amount " ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right">
                                    <ItemTemplate>
                                        <asp:Label ID="TranzactionAmount" runat="server" Text='<%# Bind("Amount","{0:0.00}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label ID="fTranzactionDate" runat="server" Text='<%# string.Format("{0:0.00}", fTranzactionAmount) %>' ></asp:Label>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="Principal" HeaderText=" Principal " DataFormatString="{0:0.00}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="Interest" HeaderText=" Interest " DataFormatString="{0:0.00}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="Fees" HeaderText=" Ex. Rate " DataFormatString="{0:0.00}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="Penalties" HeaderText=" Penalties " DataFormatString="{0:0.00}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="Rate" HeaderText=" Curs " ItemStyle-HorizontalAlign="Right" />
                                <asp:BoundField DataField="Avans" HeaderText=" Avans " ItemStyle-HorizontalAlign="Right" />
                                <asp:TemplateField HeaderText=" Action ">
                                    <ItemTemplate>
                                        <asp:LinkButton runat="server" ID="editID" Text="Edit" CommandName="Edit"></asp:LinkButton>
                                        &nbsp;
                                        <asp:LinkButton runat="server" ID="deleteID" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Sunteti sigur ca vreti sa stergeti?');"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                
                            </Columns>
                        </asp:GridView>

                    </asp:Panel>
                </div>

            </ContentTemplate>
        </ajax:TabPanel>
        <ajax:TabPanel runat="server" ID="loanDocumentsTabPanel">
            <HeaderTemplate>&nbsp; Loan Documnets &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left; width: 95%;">
                    <asp:Panel ID="loanDocumentsPanel" runat="server" Visible="true">
                        <lr:LoanRepayment ID="LoanRepaymentControl" runat="server" OnEntrySelected="RefundsSelecetd_Event" Visible="false" />
                    </asp:Panel>
                </div>
            </ContentTemplate>
        </ajax:TabPanel>
        <ajax:TabPanel runat="server" ID="templateDocumentsTabPanel">
            <HeaderTemplate>&nbsp; Template Documents &nbsp;</HeaderTemplate>
            <ContentTemplate>
                <div style="float: left;"></div>
            </ContentTemplate>
        </ajax:TabPanel>
    </ajax:TabContainer>


    <div class="table" style="display: none;">
        <div class="row">
            <div class="cell">&nbsp;La data:&nbsp;</div>
            <div class="cell">&nbsp;Contract #:&nbsp;</div>
            <div class="cell">&nbsp;Client:&nbsp;</div>
            <div class="cell">&nbsp;Curs la acordare:&nbsp;</div>
            <div class="cell">&nbsp;Curs la achitare:&nbsp;</div>
            <div class="cell">&nbsp;Suma imprumutata:&nbsp;</div>
        </div>
        <div class="row alt">
            <div class="cell">&nbsp;<asp:Label ID="dateNowLabel" runat="server"></asp:Label>&nbsp;</div>
            <div class="cell">&nbsp;<asp:Label ID="loanNrLabel" runat="server"></asp:Label>&nbsp;</div>
            <div class="cell">&nbsp;<asp:Label ID="clientNameLabel" runat="server"></asp:Label>&nbsp;</div>
            <div class="cell">&nbsp;<asp:Label ID="loanInitialChangeRateLabel" runat="server"></asp:Label>&nbsp;</div>
            <div class="cell">&nbsp;<asp:Label ID="loanRealChangeRate" runat="server"></asp:Label>&nbsp;</div>
            <div class="cell">&nbsp; in MDL&nbsp;</div>
        </div>
    </div>
    <asp:HiddenField ID="changeRateHiddenField" runat="server" />

    <!--script type="text/javascript">
           
            
</script-->
    <style>
        tr td:first-child {
            /* styles */
            text-align: center;
            font: bold 12pt/10pt Verdana;
        }

       #<% Response.Write(refundGridView.ClientID); %>>tbody>tr:last-child{text-align: center;
            font: bold 12pt/10pt Verdana;}

        tr {
            cursor: pointer;
        }

        .parentRowPlus {
            /*
          background-color: #d8ebcb;  
        */
            background-color: #ccff99;
        }

        .parentRowMinus {
            /*
            background-color: #e1eff8;
         */
            background-color: #ffcc00;
        }

        tr:hover {
            background-color: #ffeeca;
        }

        .cell {
            /*
            border-right: 1px groove orange;
        */
            padding-right: 10px;
            padding-left: 10px;
        }

        #navListParent li, #navListGeneral li, #navListMenu li, #navListTabs li {
            display: inline;
            list-style-type: none;
            padding-right: 10px;
        }
    </style>
</asp:Content>



